/*********************************************************
          File Name:11.8.cpp
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Sun 20 Sep 2015 08:04:22 PM CST
**********************************************************/

#include <iostream>
#include <vector>
#include <string>
#include <set>

// see discuss on Stack Overflow
// http://stackoverflow.com/questions/8686725/what-is-the-difference-between-stdset-and-stdvector

using std::cout;
using std::cin;
using std::endl;
using std::vector;
using std::string;

using Type = vector<string>::iterator;

class Word
{
        private:
                vector<string> words;
                bool check_unique(vector<string> &v, string &s)
                {
                        for(const auto &x: v)
                        {
                                if(x == s)
                                        return false;
                        }
                        return true;
                }
        public:
                Word() = default;
                Word(Type b, Type e)
                {
                        for(auto x = b; x != e; ++x)
                        {
                                if(check_unique(words, *x))
                                        words.push_back(*x);
                        }
                }
                ~Word() = default;

                void print()
                {
                        for(const auto &x: words)
                                cout << x << " ";
                        cout << endl;
                }
};

int main()
{
        vector<string> v{"this", "is", "is", "a", "test", "this", "test"};

        Word word(v.begin(), v.end());

        std::set<string> s(v.begin(), v.end()); // already sorted

        for(const auto &x: v)
                cout << x << " ";
        cout << endl;

        cout << "------------------------------------------" << endl;

        word.print();
        cout << "------------------------------------------" << endl;

        for(auto &x: s)
                cout << x << " ";
        cout << endl;

        return 0;
}
